﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SharingCenter.Web.Admin.Posts
{
    using SharingCenter.Web.Classes.enums;
    public partial class Category : AdminPageBase
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            FormView1.ItemInserting += new FormViewInsertEventHandler(FormView1_ItemInserting);
            FormView1.ItemInserted += new FormViewInsertedEventHandler(FormView1_ItemInserted);
            LinqDataSource1.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(LinqDataSource1_Selecting);
        }

        void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            e.WhereParameters["ContextType"] = EntityType.Default;
        }

        void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
        {
            this.SetTopMostMessage("成功添加一个讨论版块。", true);
            this.RefreshPage();
        }

        void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            //LinqDataSource1.Select = null;
            e.Values["ContextType"] = EntityType.Default;
            e.Values["PostCategoryId"] = Guid.NewGuid();
        }

        protected void CheckBox1_Load(object sender, EventArgs e)
        {
            ((CheckBox)sender).Checked = true;
        }

        protected void OrderIdTextBox_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ((TextBox)sender).Text = "1";
            }
        }
    }
}
